﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PccCommonForC;
using System.Text;

public partial class Pub_Ajax_AjaxQuery : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        Response.Expires = -1;
        Response.ContentType = "text/plain";
        ProcessPage(Request.QueryString["type"]);
        Response.End();
    }

    private void ProcessPage(string type)
    {

        if (type.ToLower() == "getbanner")
        {
            Response.Write(GetBanner());
        }
        else if (type.ToLower() == "getbanner_v1")
        {
            Response.Write(GetBanner_v1());
        }
        else if (type.ToLower() == "getnews")
        {
            Response.Write(GetNews());
        }
        else if (type.ToLower() == "getnews_v1")
        {
            Response.Write(GetNews_v1());
        }
        else if (type.ToLower() == "getsaleofproduct")
        {
            Response.Write(GetSaleOfProduct());
        }
        else if (type.ToLower() == "getmenu")
        {
            Response.Write(GetMenu());
        }
        else if (type.ToLower() == "getproductimages")
        {
            Response.Write(GetProductImages());
        }
        else if (type.ToLower() == "getmybasket")
        {
            Response.Write(GetMyBasket());
        }
        else if (type.ToLower() == "querybasket")
        {
            Response.Write((QueryBasket()));
        }
        else if (type.ToLower() == "gettopmenu")
        {
            Response.Write((GetTopMenu()));
        }
        else if (type.ToLower() == "getheadermenu")
        {
            Response.Write((GetHeaderMenu()));
        }
        else if (type.ToLower() == "getcountbasket")
        {
            Response.Write((GetCountBasket()));
        }
        else if (type.ToLower() == "getads")
        {
            Response.Write((GetAds()));
        }
        else if (type.ToLower() == "getpartner")
        {
            Response.Write((GetPartner()));
        }
        else if (type.ToLower() == "getpageviews")
        {
            Response.Write((GetPageViews()));
        }
        else if (type.ToLower() == "getinfodetailpd")
        {
            Response.Write((GetInfoDetailPD()));
        }
        else if (type.ToLower() == "updatequantitybasket")
        {
            Response.Write((UpdateQuantityBasket()));
        }
        else if (type.ToLower() == "tooltippropertiespd")
        {
            Response.Write(TooltipPropertiesPD());
        }
        else if (type.ToLower() == "gettypicalproduct")
        {
            Response.Write(Get_TypicalProduct());
        }
        else if (type.ToLower() == "footerinfo")
        {
            Response.Write(Get_FooterInfo());
        }

    }

    #region GetNews
    private string GetNews_v1()
    {
        string viewcount = System.Configuration.ConfigurationManager.AppSettings["TopNews"];
        string KindNo = "N";
        if (Request.QueryString["KindNo"] != "" && Request.QueryString["KindNo"] != null)
            KindNo = Request.QueryString["KindNo"];
        clsWebShop cls = new clsWebShop();
        PccMsg msg = new PccMsg();
        msg.CreateFirstNode("NewsID", "0");
        msg.CreateFirstNode("Title", "");
        msg.CreateFirstNode("KindNo", cls.killSQLInjection(KindNo));
        msg.CreateFirstNode("Status", "");
        msg.CreateFirstNode("ViewCount", viewcount);

        DataTable dt = null;
        dt = cls.Get_NewsByCondition(msg.GetXmlStr).Tables[0];
        string HTML = "";
        if (dt.Rows.Count > 0)
        {
            HTML += "<div  class='div_skin-tango'   style='padding:0px 2px 10px 2px;text-align:center'>";
            HTML += "  <div class='coverlblTitleProduct'>";
            HTML += "<span class='lblTitleProduct'>Tin Tức</span></div>";
            HTML += "<div class='Rotator_news' style='width:185px; text-align:left;'>";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                HTML += "<div style=' text-align:left;vertical-align:top;border-bottom: dotted 1px #e0f5f5;width:100%; ' >";
                HTML += "<ul class='fixUlBlock'>";
                HTML += "<li style='padding-top:8px; padding-bottom:3px'>";

                HTML += "<a class='lbl_Link' href='" + ResolveUrl("~/") + "nws/" + dt.Rows[i]["NewsID"].ToString() + "/" + dt.Rows[i]["KindNo"].ToString() + ".aspx'><img src=" + dt.Rows[i]["ImgUrl"].ToString() + " valign='top' align='left'  style='width:40px; height:40px; padding-right:5px'>";
                HTML += dt.Rows[i]["Title"].ToString() + "</a>";
                HTML += "</li>";
                HTML += "</ul>";
                HTML += "</div>";

            }

            HTML += " </div>";
            HTML += " </div>";
        }
        return HTML;
    }
    #endregion

    #region GetBanner
    private string GetBanner()
    {
        clsWebShop cls = new clsWebShop();
        PccMsg msg = new PccMsg();
        msg.CreateFirstNode("ID", "");
        msg.CreateFirstNode("NavigateUrl", "");
        msg.CreateFirstNode("ShowMK", "Y");
        DataTable dt = cls.Get_BannerByCondition(msg.GetXmlStr.ToString()).Tables[0];
        string HTML = "";
        if (dt.Rows.Count > 0)
        {
            HTML = "<div id='lofslidecontent41' class='lof41-slidecontent' style='width:420px; height:280px;'>";
            HTML += "<div class='preload'><div></div></div>";
            HTML += " <div class='lof41-main-outer'  style='width:420px; height:280px;'>";
            HTML += " <ul class='lof41-main-wapper'>";

            //Dung cho vong lap tiep theo
            string HTML1 = "";
            HTML1 += " <div class='lof41-navigator-wapper'>";
            HTML1 += "<div onclick='return false' href='' class='lof41-next'></div>";
            HTML1 += "<div class='lof41-navigator-outer'>";
            HTML1 += "<ul class='lof41-navigator'>";

            /////////////
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                HTML += "<li>";
                HTML += "<img src='" + ResolveUrl("~/") + dt.Rows[i]["ImgUrl"].ToString() + "'   />";
                HTML += " <div class='lof41-main-item-desc'>";
                /*   HTML += " <a href='" + dt.Rows[i]["NavigateUrl"].ToString() + "' style='color:white' class='LofTitile41'>" + dt.Rows[i]["Title"].ToString() + " </a><br>";*/
                HTML += " <div style='padding-left:5px;	font-size: 11px;font-family: Tahoma'>";
                HTML += dt.Rows[i]["Content"].ToString();
                HTML += "</div>";
                HTML += "</div>";
                HTML += "</li>";


                //Vong lap tiep theo
                HTML1 += "<li>";
                HTML1 += "<img src='" + ResolveUrl("~/") + dt.Rows[i]["ImgUrl"].ToString() + "'  />";
                HTML1 += "</li>";
            }

            HTML += "</ul>";
            HTML += "</div>";


            HTML1 += "</ul>";
            HTML1 += "</div>";

            HTML += HTML1;

            HTML += "<div onclick='return false' href='' class='lof41-previous'></div>";
            HTML += "</div>";
            HTML += "</div>";


        }
        return HTML;
    }
    #endregion
    #region GetNews
    private string LimitWord(string value)
    {
        //String html = "Whatever your html is";
        //html = Regex.Replace(html, @"</?[^>]*>", ""); 
        value = StripHtml(value, false);

        int length = 400;
        if (value.Length > length)
            return "&nbsp;&nbsp;" + value.Substring(0, length) + "...";
        else
            return "&nbsp;&nbsp;" + value;

    }

    private string StripHtml(string html, bool allowHarmlessTags)
    {
        if (html == null || html == string.Empty)
            return string.Empty;

        if (allowHarmlessTags)
            return System.Text.RegularExpressions.Regex.Replace(html, "", string.Empty);

        return System.Text.RegularExpressions.Regex.Replace(html, "<[^>]*>", string.Empty);
    }


    private string GetNews()
    {
        string viewcount = System.Configuration.ConfigurationManager.AppSettings["TopNews"];
        string KindNo = "N";
        if (Request.QueryString["KindNo"] != "" && Request.QueryString["KindNo"] != null)
            KindNo = Request.QueryString["KindNo"];
        clsWebShop cls = new clsWebShop();
        PccMsg msg = new PccMsg();
        msg.CreateFirstNode("NewsID", "0");
        msg.CreateFirstNode("Title", "");
        msg.CreateFirstNode("KindNo", cls.killSQLInjection(KindNo));
        msg.CreateFirstNode("Status", "");
        msg.CreateFirstNode("ViewCount", viewcount);

        DataTable dt = null;
        dt = cls.Get_NewsByCondition(msg.GetXmlStr).Tables[0];

        string HTML = "";
        if (dt.Rows.Count > 0)
        {
            HTML = "<div id='lofslidecontent45' class='lof-slidecontent'>";
            HTML += "<div class='preload'><div></div></div>";
            HTML += " <div class='lof-main-outer'>";
            HTML += " <ul class='lof-main-wapper'>";
            //Navigator
            string HTML1 = "";
            HTML1 += " <div class='lof-navigator-outer'>";
            HTML1 += " <ul class='lof-navigator'>";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string url = "Common/News/NewsDetail.aspx?NewsID=" + dt.Rows[i]["NewsID"].ToString();
                HTML += "<li>";
                HTML += "<img src='" + dt.Rows[i]["ImgUrl"].ToString() + "'   width='175px' height='189px' />";
                HTML += " <div class='lof-main-item-desc'>";
                HTML += " <a href='" + url + "' style='color:white' class='LofTitile'>" + dt.Rows[i]["Title"].ToString() + " </a>";
                HTML += "</br>";
                HTML += "<div class='LofContent'>" + LimitWord(StripHtml(dt.Rows[i]["Content"].ToString(), true)) + "</div>";
                HTML += "</div>";
                HTML += "</li>";

                //Navigator
                HTML1 += "<li>";
                HTML1 += "<div>";
                HTML1 += "<img src='" + dt.Rows[i]["ImgUrl"].ToString() + "'  />";
                HTML1 += " <h5><a href='" + url + "' style='color:white' class='LofTitile'>" + dt.Rows[i]["Title"].ToString() + "</a></h5>";
                HTML1 += "</div>";
                HTML1 += "</li>";


            }
            HTML += "</ul>";
            HTML += "</div>";

            HTML += HTML1;
            HTML += "</ul>";
            HTML += "</div>";
            HTML += "</div>";


        }
        return HTML;
    }
    #endregion
    #region GetMostProduct
    private string GetSaleOfProduct()
    {
        string viewcount = System.Configuration.ConfigurationManager.AppSettings["SaleOfPD"];
        clsWebShop cls = new clsWebShop();
        DataTable dt = null;
        dt = cls.GetSaleOfProduct(viewcount).Tables[0];
        string HTML = "";
        if (dt.Rows.Count > 0)
        {


            HTML += "<ul id='mycarousel' class='jcarousel-skin-tango'>";
            for (int i = 0; i < dt.Rows.Count; i++)
            {

                string LinkURL = ResolveUrl("~/") + "Detail/" + CancelAccentedVN(dt.Rows[i]["CatName"].ToString()) + "/" + dt.Rows[i]["PDID"].ToString() + "/" + CancelAccentedVN(dt.Rows[i]["PDName"].ToString());

                string img = dt.Rows[i]["ImgUrl"].ToString();
                if (img == "" || img == null)
                    img = ResolveUrl("~/") + "Images/Body/Noimages.gif";
                HTML += "<li>";

                HTML += "<div div='divCoverCart'   refID='CoverCartID'>";

                HTML += "<div class='divBlock' style='text-align: center'>";
                HTML += "<img src='" + img + "' alt=''  class='img_Product'/><br>";
                HTML += "<a href='" + LinkURL + "' class='lbl_MostTitleProduct'  style='cursor: pointer'><span class='lbl_TitleProduct'>" + dt.Rows[i]["PDName"].ToString() + "</span></a>";
                HTML += "</div>";
                HTML += "<div class='divBlock' style='text-align: left;padding:5px'>";

                if (dt.Rows[i]["KindNo"].ToString() != "F")
                {
                    string isSaleof = dt.Rows[i]["IsSaleOf"].ToString();
                    string classSaleOf = "";
                    if (isSaleof == "Y" || dt.Rows[i]["Status"].ToString() == "C")
                        classSaleOf = "  class='td_linethrought'";

                    HTML += "<ul class='fixUlBlock'>";
                    HTML += "<li>";
                    HTML += "<span class='lbl_TitlePrice' >Bảo hành: </span>";
                    HTML += "<span class='lbl_Properties'>" + dt.Rows[i]["Warranty"].ToString() + "</span>";
                    HTML += "<span class='lbl_TitlePrice'>Tháng</span>";
                    HTML += "</li>";
                    HTML += "<li>";
                    HTML += "<div " + classSaleOf + ">";
                    HTML += "<span class='lbl_TitlePrice'>Giá: </span>";
                    HTML += "<span class='lbl_Price' >" + FormatMoney(dt.Rows[i]["Price"].ToString()) + "</span> ";
                    HTML += "<span class='lbl_Rate'>" + dt.Rows[i]["Rate"].ToString() + "</span>";
                    HTML += "</li>";

                    if (isSaleof == "Y")
                    {
                        HTML += "<li>";
                        HTML += "<span class='lbl_TitlePrice'>Chỉ còn: </span>";
                        HTML += "<span class='lbl_Price'>" + FormatMoney(dt.Rows[i]["DiscountPrice"].ToString()) + "</span> ";
                        HTML += "<span class='lbl_Rate'>" + dt.Rows[i]["DiscountRate"].ToString() + "</span>";
                        HTML += "</li>";

                    }
                    HTML += "</ul>";
                }

                HTML += "</div>";//"div KindNo"


                string cssAdd = " display: block ";
                string cssCancel = " display: none  ";
                if (Session["dtBasket"] != null)
                {
                    DataTable dtBasket = (DataTable)Session["dtBasket"];
                    if (SearchDataTable(dtBasket, "PDID", dt.Rows[i]["PDID"].ToString()) != -1)
                    {
                        cssAdd = " display: none ";
                        cssCancel = " display: block  ";

                    }
                }


                HTML += "<table border='0' cellpadding='0' cellspacing='0' class='divBlock' style='text-align: right; float: right'>";
                HTML += "    <tr>";
                if (dt.Rows[i]["IsHot"].ToString() == "Y")
                {
                    HTML += "<td>";
                    HTML += "<img src='Images/Icon/hot.gif' /></td>";
                }

                HTML += "    <td>";
                HTML += "      <a href='" + LinkURL + "'>";
                HTML += " <img src='Images/Icon/detail.gif' style='cursor: pointer;' /></a>";
                HTML += "   </td>  <td>";
                HTML += "   <img class='cssAddBasket' pdid='" + dt.Rows[i]["pdid"].ToString() + "' pdname='" + dt.Rows[i]["pdname"].ToString() + "'   price='" + dt.Rows[i]["Price"].ToString() + "' rate='" + dt.Rows[i]["rate"].ToString() + "' kindno='" + dt.Rows[i]["kindno"].ToString() + "'   DiscountPrice='" + dt.Rows[i]["DiscountPrice"].ToString() + "'     DiscountRate='" + dt.Rows[i]["DiscountRate"].ToString() + "'     IsSaleOf='" + dt.Rows[i]["IsSaleOf"].ToString() + "'    src='Images/Icon/buy.gif' style='cursor: pointer; " + cssAdd + "' id='btnISelect'  /></td>";
                HTML += "   <td>";
                HTML += " <img src='Images/Icon/cancel.GIF' class='cssCancelBasket' style='cursor: pointer;     " + cssCancel + "' id='btnICancel' runat='server' pdid='" + dt.Rows[i]["pdid"].ToString() + "' /></td>";
                HTML += "   </tr>";
                HTML += " </table>";

                HTML += "</div>";

                HTML += "</li>";
            }
            HTML += "</ul>";



        }
        return HTML;
    }
    #region Old
    private string GetMostProduct_v1()
    {
        string viewcount = System.Configuration.ConfigurationManager.AppSettings["MostPD"];
        clsWebShop cls = new clsWebShop();
        DataTable dt = null;
        dt = cls.Get_Most_ProductNoneProc(viewcount).Tables[0];
        string HTML = "";
        if (dt.Rows.Count > 0)
        {
            HTML = "<div id='lofslidecontent46' class='lof46-slidecontent' style='width:200px; height:200px;'>";
            HTML += "<div class='preload'><div></div></div>";
            HTML += "    <div class='lof46-main-outer' style='width:200px; height:190px;'>";
            HTML += " <div onclick='return false' href='' class='lof46-previous'>Previous</div>";
            HTML += "   	<ul class='lof46-main-wapper'>";


            for (int i = 0; i < dt.Rows.Count; i++)
            {
                HTML += "<li>";
                HTML += "<img src='" + ResolveUrl("~/") + dt.Rows[i]["ImgUrl"].ToString() + "' alt=''  class='img_Product' />";
                HTML += "<div class='lof46-main-item-desc'>";

                HTML += "<a href='" + ResolveUrl("~/") + "Shopping/Stall/ProductDetail.aspx?PDID=" + dt.Rows[i]["PDID"].ToString() + "'>" + dt.Rows[i]["PDName"].ToString() + "</a>";
                HTML += "  </div>";
                HTML += "</li>";

            }
            HTML += " </ul>  ";
            HTML += " <div onclick='return false' href='' class='lof46-next'>Next</div>";
            HTML += " </div>  ";
            //    ltrMaster.Text = HTML;
        }
        return HTML;
    }
    #endregion
    #endregion
    #region GetMenu
    private string GetMenu()
    {

        clsWebShop cls = new clsWebShop();
        DataTable dtTopic = new DataTable();
        DataTable dtCat = new DataTable();
        PccMsg msg = new PccMsg();
        msg.CreateFirstNode("KindNo", "P");
        DataSet ds = cls.Get_Topic_Catalogue(msg.GetXmlStr);
        dtTopic = ds.Tables[0];
        dtCat = ds.Tables[1];

        string HTML = "<div class='glossymenu'>";
        string TopicID, TopicName, CatID, CatName;
        string Url = ResolveUrl("~/");
        foreach (DataRow rowTopic in dtTopic.Rows)//Cap Cha
        {

            TopicID = rowTopic["TopicID"].ToString();
            TopicName = rowTopic["TopicName"].ToString();

            DataRow[] rowCat;
            rowCat = dtCat.Select("TopicID=" + TopicID);

            if (rowCat.Length > 0)
            {
                HTML += "<a class='menuitem submenuheader'   href='" + Url + "Stall/" + TopicID + "/0.aspx'>" + TopicName + "</a>";
                HTML += "<div class='submenu'>";
                HTML += "<ul>";
                for (int i = 0; i < rowCat.Length; i++)
                {
                    CatID = rowCat[i]["CatID"].ToString();
                    CatName = rowCat[i]["CatName"].ToString();
                    HTML += "<li><a href='" + Url + "Stall/0/" + CatID + ".aspx'>" + CatName + "</a></li>";
                }
                HTML += "</ul>";
                HTML += "</div>";
            }
            else
            {
                HTML += "<a class='menuitem' href='" + Url + "Shopping/Stall/Stall.aspx?TopicID=" + TopicID + ".aspx'>" + TopicName + "</a>";
            }
        }
        HTML += "</div>";

        return HTML;


    }
    #endregion
    #region GetProductImages
    private string GetProductImages()
    {
        DataTable dt = new DataTable();
        string HTML = "";
        if (Request.QueryString["PDID"] != "" && Request.QueryString["PDID"] != null)
        {
            clsWebShop cls = new clsWebShop();
            PccMsg msg = new PccMsg();
            msg.CreateFirstNode("PDID", Request.QueryString["PDID"]);
            dt = cls.Get_Product_IMGByCondition(msg.GetXmlStr).Tables[0];


            if (dt.Rows.Count > 0)
            {
                HTML += "<ul class='pop' id='top' >";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string sURL = dt.Rows[i]["ImgPD_Url"].ToString();
                    if (sURL.IndexOf("http://") == -1)//Khong tim thay
                    {
                        sURL = ResolveUrl("~/") + sURL;
                    }
                    HTML += "<li style='padding-right:10px; background-color: lightyellow;'><span>" + dt.Rows[i]["ImgPD_Desc"].ToString() + "</span><a href='" + sURL + "'><img src='" + sURL + "' width='40px' height='40px'/></a></li>";
                }
                HTML += "</ul>";

            }
            //else
            //{
            //    return "<h4 style='color:green'>Không có hình ảnh nào cho sản phẩm này</h4>";
            //}
        }
        return HTML;

    }


    #endregion
    #region GetMyBasket
    private DataTable GetDataBasket()
    {
        string sSession = "dtBasket";
        if (Request.QueryString["KindNo"] == "F")
            sSession = "dtBasketFilm";
        DataTable dtBasket = new DataTable();
        if (Session[sSession] != null)
            dtBasket = (DataTable)Session[sSession];
        return dtBasket;
    }
    private string GetMyBasket()
    {
        string HTML = "<table border='0' cellpadding='2' cellspacing='5' width='100%'>";
        DataTable dt = GetDataBasket();

        if (dt.Rows.Count > 0)
        {
            clsWebShop cls = new clsWebShop();

            if (Request.QueryString["KindNo"] == "F")
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //string strUrl = ResolveUrl("~/Shopping/Stall/ProductDetail.aspx") + "?PDID=" + dt.Rows[i]["PDID"].ToString();
                    DataRow rowPD;
                    rowPD = cls.GetData("select * from Film  where FilmID='" + dt.Rows[i]["PDID"].ToString() + "'").Tables[0].Rows[0];
                    string strUrl = ResolveUrl("~/") + "Detail/_/" + dt.Rows[i]["PDID"].ToString() + "/" + CancelAccentedVN(rowPD["FilmEng"].ToString() + ".aspx");

                    string img = rowPD["ImgUrl"].ToString();
                    if (img == "" || img == null)
                        img = "Images/Body/Noimages.gif";

                    HTML += "<tr>";
                    HTML += "<td style='	white-space:nowrap;' width='55px'>";
                    HTML += "<font style='font-size:10px;font-weight:bold'><img src='" + ResolveUrl("~/") + img + "' width='65px' height='70px'></font></td>";
                    HTML += "<td style='text-align:left;vertical-align:top; padding-left:10px'>";
                    HTML += "<span>" + dt.Rows[i]["PDName"].ToString() + "</span>";


                    HTML += "</td>";
                    HTML += "</tr>";
                }
            }
            else
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //string strUrl = ResolveUrl("~/Shopping/Stall/ProductDetail.aspx") + "?PDID=" + dt.Rows[i]["PDID"].ToString();
                    DataRow rowPD;
                    rowPD = cls.GetData("select * from Product  where PDID='" + dt.Rows[i]["PDID"].ToString() + "'").Tables[0].Rows[0];



                    string strUrl = ResolveUrl("~/") + "Detail/_/" + dt.Rows[i]["PDID"].ToString() + "/" + CancelAccentedVN(rowPD["PDName"].ToString() + ".aspx");

                    string img = rowPD["ImgUrl"].ToString();
                    if (img == "" || img == null)
                        img = "Images/Body/Noimages.gif";

                    HTML += "<tr>";
                    HTML += "<td style='	white-space:nowrap;' width='55px'>";
                    HTML += "<font style='font-size:10px;font-weight:bold'><a href='" + strUrl + "'><img src='" + ResolveUrl("~/") + img + "' width='65px' height='70px'></a></font></td>";
                    HTML += "<td style='text-align:left;vertical-align:top; padding-left:10px'><a href='" + strUrl + "' class='lbl_Default' style='text-decoration: none; font-family: Tahoma; font-size: 11px;font-weight:bold'>";
                    HTML += "<span>" + dt.Rows[i]["PDName"].ToString() + "</span></a>";
                    if (dt.Rows[i]["KindNo"].ToString() == "P")
                    {
                        HTML += "Giá: <span class='lbl_Price' style='font-size:11px'>" + FormatMoney(dt.Rows[i]["Price"].ToString()) + "</span> <span>" + dt.Rows[i]["Rate"].ToString() + "</span>";
                    }

                    HTML += "</td>";
                    HTML += "</tr>";
                }
            }

        }
        else
        {
            HTML += "<tr>";
            HTML += "<div class='lbl_TextDefault' width='100%' align='center'>Giỏ hàng của bạn chưa có sản phẩm nào</div>";
            HTML += "</tr>";
        }
        HTML += "</table>";
        return HTML;


    }
    #endregion
    #region QueryBasket
    private string QueryBasket()
    {
        string sSession = "dtBasket";
        DataTable dtBasket = new DataTable();
        if (Request.QueryString["KindNo"] == "F")
            sSession = "dtBasketFilm";

        FilterBasket(sSession);

        return "ok";

    }

    private void FilterBasket(string sSession)
    {
        DataTable dtBasket = new DataTable();
        if (Session[sSession] != null)
        {
            dtBasket = (DataTable)Session[sSession];
        }
        else if (Request.QueryString["KindNo"] == "F")
        {
            dtBasket.Columns.Add("PDID");
            dtBasket.Columns.Add("PDNAME");
            dtBasket.Columns.Add("KINDNO");
            dtBasket.Columns.Add("CAPACITY");
            dtBasket.Columns.Add("FilmNo");
        }
        else
        {
            dtBasket.Columns.Add("PDID");
            dtBasket.Columns.Add("PDNAME");
            dtBasket.Columns.Add("PRICE");
            dtBasket.Columns.Add("QUANTITY");
            dtBasket.Columns.Add("RATE");
            dtBasket.Columns.Add("KINDNO");
            dtBasket.Columns.Add("CAPACITY");
        }

        if (Request.QueryString["KindNo"] == "P")
        {
            if (Request.QueryString["type1"].ToLower() == "addbasket")
            {
                AddBasket(dtBasket, sSession);
            }
            else if (Request.QueryString["type1"].ToLower() == "cancelbasket")
            {
                CancelBasket(dtBasket, sSession);
            }
        }
        else
        {
            if (Request.QueryString["type1"].ToLower() == "addbasket")
            {
                AddBasketFilm(dtBasket, sSession);
            }
            else if (Request.QueryString["type1"].ToLower() == "cancelbasket")
            {
                CancelBasket(dtBasket, sSession);
            }
        }

    }

    private string AddBasketFilm(DataTable dtBasket, string sSession)
    {
        string strPDID = Request.QueryString["PDID"];
        clsCommon clsCom = new clsCommon();
        int index = clsCom.SearchDataTable(dtBasket, "PDID", Request.QueryString["PDID"]);
        if (index != -1) return "ok";
        string strPDName = Request.QueryString["PDNAME"];
        string strPDKindNo = Request.QueryString["KINDNO"];
        string strCapacity = Request.QueryString["CAPACITY"];
        string FilmNo = Request.QueryString["FilmNo"];
        clsWebShop cls = new clsWebShop();
        cls.UpdateViewCountFilm(strPDID);

        DataRow row = dtBasket.NewRow();
        row["PDID"] = strPDID;
        row["PDNAME"] = strPDName;
        row["KINDNO"] = strPDKindNo;
        row["CAPACITY"] = strCapacity;
        row["FilmNo"] = FilmNo;
        dtBasket.Rows.Add(row);
        Session[sSession] = dtBasket;

        return "ok";
    }

    private string AddBasket(DataTable dtBasket, string sSession)
    {
        string strPDID = Request.QueryString["PDID"];
        clsCommon clsCom = new clsCommon();
        int index = clsCom.SearchDataTable(dtBasket, "PDID", Request.QueryString["PDID"]);
        if (index != -1) return "ok";
        string strPDName = Request.QueryString["PDNAME"];
        string strPDPrice = Request.QueryString["PRICE"];
        string strQuantity = Request.QueryString["QUANTITY"];
        string strPDRate = Request.QueryString["RATE"];
        string strPDKindNo = Request.QueryString["KINDNO"];
        string strCapacity = Request.QueryString["CAPACITY"];

        if (Request.QueryString["IsSaleOf"] == "Y")
        {
            strPDPrice = Request.QueryString["DiscountPrice"];
            strPDRate = Request.QueryString["DiscountRate"];
        }

        clsWebShop cls = new clsWebShop();
        cls.UpdateViewCount(strPDID);

        DataRow row = dtBasket.NewRow();
        row["PDID"] = strPDID;
        row["PDNAME"] = strPDName;
        row["PRICE"] = strPDPrice;
        row["QUANTITY"] = strQuantity;
        row["RATE"] = strPDRate;
        row["KINDNO"] = strPDKindNo;
        row["CAPACITY"] = strCapacity;
        dtBasket.Rows.Add(row);
        Session[sSession] = dtBasket;

        return "ok";
    }
    private string CancelBasket(DataTable dtBasket, string sSession)
    {
        clsCommon clsCom = new clsCommon();
        int index = clsCom.SearchDataTable(dtBasket, "PDID", Request.QueryString["PDID"]);
        if (index != -1)
        {
            dtBasket.Rows[index].Delete();
        }
        Session[sSession] = dtBasket;
        return "ok";
    }

    private string GetTopMenu()
    {
        clsWebShop cls = new clsWebShop();
        DataTable dtTopic = new DataTable();
        DataTable dtCat = new DataTable();
        PccMsg msg = new PccMsg();
        msg.CreateFirstNode("KindNo", "P");
        DataSet ds = cls.Get_Topic_Catalogue(msg.GetXmlStr);



        dtTopic = ds.Tables[0];
        dtCat = ds.Tables[1];

        DataTable dtHTML = new DataTable("Table");
        dtHTML.Columns.Add("HTML1");
        dtHTML.Columns.Add("HTML2");
        dtHTML.Columns.Add("HTML3");

        #region "HTML1"
        string HTML = "";
        string TopicID, TopicName, CatID, CatName;
        string Url = ResolveUrl("~/");
        HTML += "<table border='0' cellpadding='0' cellspacing='0' width='100%'>";
        HTML += "<tr>";
        string strTd = "";
        for (int k = 0; k < dtTopic.Rows.Count; k++)//Cap Cha
        {
            TopicID = dtTopic.Rows[k]["TopicID"].ToString();
            TopicName = dtTopic.Rows[k]["TopicName"].ToString();
            DataRow[] rowCat;
            rowCat = dtCat.Select("TopicID=" + TopicID+ " and KindNo='P'");
            strTd = "<td style='white-space:nowrap; vertical-align:top'>";
            strTd += "<ol class='ulTagP'>";
            strTd += "<li><a href='" + Url + "Stall/" + TopicID + "/0/" + CancelAccentedVN(TopicName) + "/0.aspx'><img src='" + ResolveUrl("~/") + "Images/Icon/bullet_icon.gif' >  " + TopicName + "</a>";
            if (rowCat.Length > 0)
            {
                strTd += "<ol>";
                for (int i = 0; i < rowCat.Length; i++)
                {
                    CatID = rowCat[i]["CatID"].ToString();
                    CatName = rowCat[i]["CatName"].ToString();
                    strTd += "<li><a href='" + Url + "Stall/0/" + CatID + "/" + CancelAccentedVN(TopicName) + "/" + CancelAccentedVN(CatName) + ".aspx'><img src='" + ResolveUrl("~/") + "Images/Icon/IconBullet.jpg' > " + CatName + "</a></li>";
                }
                strTd += "</ol>";
            }
            strTd += "</li></ol>";
            strTd += "</td>";
            if ((k + 1) % 4 == 0)
            {
                strTd += "</tr><tr>";
                HTML += strTd;
                strTd = "";
            }
            else
                HTML += strTd;

        }
        HTML += "</tr>";
        HTML += "</table>";



        DataRow row = dtHTML.NewRow();
        row["HTML1"] = HTML;

        #endregion
        #region "HTML2"
        HTML = "";
        DataTable dt = new DataTable();

        dt = cls.Get_CatalogByKindNo("F").Tables[0];


        for (int i = 0; i < dt.Rows.Count; i++)
        {
            HTML += "<ol class='ulTagP'>";
            HTML += "<li><a href='" + Url + "Film/0/" + dt.Rows[i]["CatID"].ToString() + "/0/" + CancelAccentedVN(dt.Rows[i]["CatName"].ToString()) + ".aspx'><img src='" + ResolveUrl("~/") + "Images/Icon/movieforum_old-48.png' > " + dt.Rows[i]["CatName"].ToString() + "</a></li>";
            HTML += "</ol>";
        }

        row["HTML2"] = HTML;
        #endregion


        #region "HTML3"
        HTML = "<font class='UnderlineFont'>Hỗ trợ trực tuyến</font><br><br><font style='float:left;'>YM: </font>";
        msg = new PccMsg();
        msg.CreateFirstNode("OnlineID", "0");
        msg.CreateFirstNode("OnlineName", "");
        msg.CreateFirstNode("NickName", "");
        dt = null;
        dt = cls.Get_OnlineSurportByCondition(msg.GetXmlStr).Tables[0];


        for (int i = 0; i < dt.Rows.Count; i++)
        {
            HTML += "<ol class='ulTagP'>";
            HTML += "<li><a href = 'ymsgr:sendIM?" + dt.Rows[i]["NickName"].ToString() + "'  class='lblTitleNews'><img src='http://opi.yahoo.com/online?u=" + dt.Rows[i]["NickName"].ToString() + "&m=g&t=0' border='0' align='left' style='padding-right:5px'>" + dt.Rows[i]["NickName"].ToString() + "</a>";


            HTML += "</li>";
            HTML += "</ol>";
        }

        HTML += "<br><br><div align='center'>Thời gian: 9h00 - 21h00 <br>Ngoài giờ hành chính bạn có thể email tới " + ConfigurationManager.AppSettings["SuperEmail"] + " <br><font class='HotLine'> Tel : 08.62909077 - 08.62909078 - Hotline: 0982600917 <br> Fax: 08.62909079 <br></font>Showroom: 16/83 Nguyễn Thiện Thuật, P2, Q3, TP.HCM <br>Website: www.HoangNguyenBao.com</div>";
        row["HTML3"] = HTML;
        #endregion


        dtHTML.Rows.Add(row);
        return GetJSONString(dtHTML);

    }


    #endregion
    #region Get_TypicalProduct
    private string Get_TypicalProduct()
    {
        string viewcount = System.Configuration.ConfigurationManager.AppSettings["TopTypicalProduct"];
        clsWebShop cls = new clsWebShop();
        PccMsg msg = new PccMsg();
        msg.CreateFirstNode("ViewCount", viewcount);

        DataTable dt = null;
        dt = cls.Get_TypicalProduct(msg.GetXmlStr).Tables[0];
        string HTML = "";
        if (dt.Rows.Count > 0)
        {
            HTML += "<div  class='div_skin-tango'  style='padding: 0px 2px 10px 2px;text-align:center'>";
            HTML += "  <div class='coverlblTitleProduct'>";
            HTML += "<span class='lblTitleProduct'>SẢN PHẨM TIÊU BIỂU</span></div>";
            HTML += "<div class='Rotator_TypicalProduct' style='width:175px; text-align:left;'>";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string strUrl = ResolveUrl("~/") + "Detail/_/" + dt.Rows[i]["PDID"].ToString() + "/" + CancelAccentedVN(dt.Rows[i]["PDName"].ToString() + ".aspx");

                HTML += "<div style=' text-align:left;vertical-align:top;border-bottom: dotted 1px #e0f5f5;width:100%; ' >";
                HTML += "<ul class='fixUlBlock'>";
                HTML += "<li style='padding-top:8px; padding-bottom:3px'>";
                HTML += "<table width='100%' cellpadding='0' cellspacing='0'>";
                HTML += "<tr>";
                HTML += "<td>";
                HTML += "<a class='lbl_Link' href='" + strUrl + "'><img src=" + ResolveUrl("~/") + Server.UrlPathEncode(dt.Rows[i]["ImgUrl"].ToString()) + " valign='top' align='left'  style='width:40px; height:40px; padding-right:5px'></a>";
                HTML += "</td>";
                HTML += "<td valign='top'>";
                HTML += "<a class='lbl_Link' href='" + strUrl + "'>" + dt.Rows[i]["PDName"].ToString() + "</a><br><a class='lbl_Link' href='" + strUrl + "'><span style='white-space:nowrap'>Giá: <span class='lbl_Price' style='font-size:10px'>" + FormatMoney(dt.Rows[i]["Price"].ToString()) + " </span>" + dt.Rows[i]["Rate"].ToString() + "</span></a>";
                HTML += "</td>";
                HTML += "</tr>";
                HTML += "</table>";


                HTML += "</li>";
                HTML += "</ul>";
                HTML += "</div>";

            }

            HTML += " </div>";
            HTML += " </div>";
        }
        return HTML;
    }
    #endregion
    private string GetBanner_v1()
    {
        clsWebShop cls = new clsWebShop();
        PccMsg msg = new PccMsg();
        msg.CreateFirstNode("ID", "");
        msg.CreateFirstNode("NavigateUrl", "");
        msg.CreateFirstNode("ShowMK", "Y");
        DataTable dt = cls.Get_BannerByCondition(msg.GetXmlStr.ToString()).Tables[0];
        string HTML = "";

        if (dt.Rows.Count > 0)
        {
            HTML = "";
            HTML += "<div class='preload'><div></div></div>";
            HTML += " <div class='lof-main-outer'>";
            HTML += " <ul class='lof-main-wapper'>";
            //Navigator
            string HTML1 = "";
            HTML1 += " <div class='lof-navigator-outer'>";
            HTML1 += " <ul class='lof-navigator'>";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string URL = "#";
                if (dt.Rows[i]["NavigateUrl"].ToString() != "")
                    URL = dt.Rows[i]["NavigateUrl"].ToString();
                HTML += "<li>";
                HTML += "<a href='" + URL + "'><img src='" + dt.Rows[i]["ImgUrl"].ToString() + "'/></a>";
                HTML += " <div class='lof-main-item-desc'>";
                HTML += "<div class='LofContent'>" + dt.Rows[i]["Content"].ToString() + "</div>";
                HTML += "</div>";
                HTML += "</li>";

                //Navigator
                HTML1 += "<li>";
                HTML1 += "<div>";
                HTML1 += "<img src='" + dt.Rows[i]["ImgUrl"].ToString() + "'  />";
                HTML1 += " <h5><a href='" + URL + "' style='color:white' class='LofTitile'>" + LimitWord(dt.Rows[i]["Title"].ToString(), 100) + "</a></h5>";
                HTML1 += "</div>";
                HTML1 += "</li>";


            }
            HTML += "</ul>";
            HTML += "</div>";

            HTML += HTML1;
            HTML += "</ul>";
            HTML += "</div>";
            HTML += "";


        }
        return HTML;
    }

    private string GetHeaderMenu()
    {
        clsWebShop cls = new clsWebShop();
        DataTable dt = new DataTable();
        dt = cls.Get_Menu_HomeNoneProc().Tables[0];
        string HTML = "";

        HTML += "<table border='0' cellpadding='0' cellspacing='0' width='100%' class='HeaderMenuM'>";
        HTML += "<tr>";
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            HTML += "<td>";
            HTML += "<a href='" + ResolveUrl("~/") + dt.Rows[i]["MenuURL"].ToString() + "'>" + dt.Rows[i]["MenuName"].ToString() + "</a>";
            HTML += "</td>";

        }
        HTML += "</tr>";
        HTML += "</table>";

        return HTML;
    }
    private string GetPageViews()
    {
        clsWebShop cls = new clsWebShop();
        DataTable dt = new DataTable();
        dt = cls.Get_Menu_HomeNoneProc().Tables[0];
        string HTML = "";

        HTML += "<div class='div_skin-tango' style='padding: 0px 2px 10px 2px; text-align: center'>";
        HTML += "  <ul class='fixUlBlock'>";
        HTML += "  <li style='padding-bottom:5px'>";
        HTML += "  <div class='coverlblTitleProduct'>";
        HTML += "  <span class='lblTitleProduct'>THỐNG KÊ</span></div></li>";
        HTML += "  <li>";
        // HTML += "       <img src='http://hitwebcounter.com/counter/counter.php?page=200060&style=0002&nbdigits=7&type=ip&initCount=8136' title='' Alt=''   border='0' ></li>";
        //  HTML += "   <li>";
        //  HTML += "       <span style='font-size:8pt' class='cssPathLink'>Hiện đang có " + Application["OnlineCount"].ToString() + " người đang Online</span></li>";

        HTML += "<a href='http://www.histats.com' alt='page hit counter' target='_blank'>";
        HTML += "      <embed src='http://s10.histats.com/493.swf' flashvars='jver=1&acsid=1520939&domi=4'";
        HTML += "         quality='high' width='112' height='61' name='493.swf' align='middle' type='application/x-shockwave-flash'   pluginspage='http://www.macromedia.com/go/getflashplayer' wmode='transparent' /></a>";
        //   HTML += " <img src='http://sstatic1.histats.com/0.gif?1520939&101' alt='web hit counter' border='0'>";


        HTML += "   <li>";
        HTML += " </ul>";
        HTML += "</div>";

        return HTML;
    }
    private string GetAds()
    {
        clsWebShop cls = new clsWebShop();
        string KindNo = "A";
        string Title = "QUẢNG CÁO";
        string width = "175px";
        if (Request.QueryString["KindNo"] == "P")
        {
            KindNo = "P";
            Title = "ĐỐI TÁC";
            width = "185px";
        }

        DataTable dt = cls.GetData("select * from Ads  Where KindNo='" + KindNo + "' and Status<>'D' ORDER BY NEWID()").Tables[0];

        string HTML = "";

        HTML += "<div class='div_skin-tango' style='padding: 0px 2px 10px 2px; text-align: center; width:" + width + "'>";
        HTML += "<ul class='fixUlBlock'>";
        HTML += "  <li style='padding-bottom:5px'>";
        HTML += "  <div class='coverlblTitleProduct'>";
        HTML += "  <span class='lblTitleProduct'>" + Title + "</span></div></li>";
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            HTML += "<li>";
            if (dt.Rows[i]["AdsType"].ToString().ToUpper() == "IMG")
            {
                HTML += " <a target='_blank' href='" + dt.Rows[i]["AdsLink"].ToString() + "'> <img border='0' src='" + ResolveUrl("~/" + dt.Rows[i]["AdsURL"].ToString()) + "' width='90%'></a>";

            }
            else if (dt.Rows[i]["AdsType"].ToString().ToUpper() == "SWF")
            {
                HTML += "<a  target='_blank' href='" + dt.Rows[i]["AdsLink"].ToString() + "'><embed quality='high'   src='" + ResolveUrl("~/" + dt.Rows[i]["AdsURL"].ToString()) + "'  loop='false' width='90%' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'> </embed> </a>";

            }
            HTML += "</li>";

        }

        HTML += "</ul>";
        HTML += "</div>";

        return HTML;
    }
    /*  private string GetPartner()
      {
          clsWebShop cls = new clsWebShop();

          DataTable dt = cls.GetData("select * from Ads  Where KindNo='P' and Status<>'D' order by UpdDate Desc").Tables[0];

          string HTML = "";

          HTML += "<div class='div_skin-tango' style='padding: 0px 2px 10px 2px; text-align: center'>";
          HTML += "<ul class='fixUlBlock'>";
          HTML += "  <li style='padding-bottom:5px'>";
          HTML += "  <div class='coverlblTitleProduct'>";
          HTML += "  <span class='lblTitleProduct'>Quảng cáo</span></div></li>";
          for (int i = 0; i < dt.Rows.Count; i++)
          {
              HTML += "<li>";
              if (dt.Rows[i]["AdsType"].ToString().ToUpper() == "IMG")
              {
                  HTML += " <a target='_blank' href='" + dt.Rows[i]["AdsLink"].ToString() + "'> <img border='0' src='" + ResolveUrl("~/" + dt.Rows[i]["AdsURL"].ToString()) + "' width='170px'></a>";

              }
              else if (dt.Rows[i]["AdsType"].ToString().ToUpper() == "SWF")
              {
                  HTML += "<a  target='_blank' href='" + dt.Rows[i]["AdsLink"].ToString() + "'><embed quality='high'   src='" + ResolveUrl("~/" + dt.Rows[i]["AdsURL"].ToString()) + "'  loop='false' width='170px' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'> </embed> </a>";

              }
              HTML += "</li>";

          }

          HTML += "</ul>";
          HTML += "</div>";

          return HTML;
      }*/

    private string GetPartner()
    {
        clsWebShop cls = new clsWebShop();

        DataTable dt = cls.GetData("select * from Ads  Where KindNo='P' and Status<>'D' order by UpdDate Desc").Tables[0];

        string HTML = "";



        for (int i = 0; i < dt.Rows.Count; i++)
        {
            HTML += "<ul class='fixUlBlock' >";
            HTML += "<li>";
            if (dt.Rows[i]["AdsType"].ToString().ToUpper() == "IMG")
            {
                HTML += " <a target='_blank' href='" + dt.Rows[i]["AdsLink"].ToString() + "'> <img border='0' src='" + ResolveUrl("~/" + dt.Rows[i]["AdsURL"].ToString()) + "' width='580px' ></a>";

            }
            else if (dt.Rows[i]["AdsType"].ToString().ToUpper() == "SWF")
            {
                HTML += "<a  target='_blank' href='" + dt.Rows[i]["AdsLink"].ToString() + "'><embed quality='high'   src='" + ResolveUrl("~/" + dt.Rows[i]["AdsURL"].ToString()) + "'  loop='false' width='175px' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'> </embed> </a>";

            }
            HTML += "</li>";
            HTML += "</ul>";

        }



        return HTML;
    }
    private string TooltipPropertiesPD()
    {
        PccMsg msg;
        clsWebShop cls = new clsWebShop();
        string HTML = "";
        string PDID = Request.QueryString["PDID"];
        string CatID = Request.QueryString["CatID"];
        string KindNo = Request.QueryString["KindNo"];
        if (KindNo == "F")
        {
            msg = new PccMsg();
            msg.CreateFirstNode("CatID", CatID);
            msg.CreateFirstNode("TopicID", "0");
            msg.CreateFirstNode("KindNo", "F");
            msg.CreateFirstNode("PDID", PDID);
            DataTable dt = null;
            dt = cls.Get_FilmByCondition(msg.GetXmlStr).Tables[0];

            if (dt.Rows.Count > 0)
            {
                HTML += "<span class='lbl_Property-BigSizeBoldD' style='color:green; font-weight:bold; padding: 0px 0px 5px 0px;white-space:nowrap;'>Thông tin phim</span><br>";
                HTML += "<ul style='padding: 2px 2px 2px 15px; list-style-type:disc; margin: 0;width:300px'>";
                HTML += "<li><span style='text-transform:capitalize; color:MidnightBlue;'>Thể loại:</span> <span class='lbl_PriceDetailD' style='font-size:12px'>" + dt.Rows[0]["CatName"].ToString() + "</span></li>";
                HTML += "<li><span style='text-transform:capitalize; color:MidnightBlue;'>Đạo diễn:</span> <span class='lbl_PriceDetailD' style='font-size:12px'>" + dt.Rows[0]["Director"].ToString() + "</span></li>";
                HTML += "<li><span style='text-transform:capitalize; color:MidnightBlue;'>Diễn viên:</span> <span class='lbl_PriceDetailD' style='font-size:12px'>" + dt.Rows[0]["Hero"].ToString() + "</span></li>";
                HTML += "<li><span style='text-transform:capitalize; color:MidnightBlue;'>Quốc gia:</span> <span class='lbl_PriceDetailD' style='font-size:12px'>" + dt.Rows[0]["National"].ToString() + "</span></li>";
                HTML += "<li><span style='text-transform:capitalize; color:MidnightBlue;'>Phụ đề:</span> <span class='lbl_PriceDetailD' style='font-size:12px'>" + dt.Rows[0]["Subtitles"].ToString() + "</span></li>";
                HTML += "<li><span style='text-transform:capitalize; color:MidnightBlue;'>Dung lượng:</span> <span class='lbl_PriceDetailD' style='font-size:12px'>" + dt.Rows[0]["Capacity"].ToString() + " GB</span></li>";
                HTML += "<li><span style='text-transform:capitalize; color:MidnightBlue;'>Âm thanh:</span> <span class='lbl_PriceDetailD' style='font-size:12px'>" + dt.Rows[0]["Sound"].ToString() + "</span></li>";                          
                HTML += "</ul>";
                HTML += "<span class='lbl_Property-BigSizeBoldD' style='color:green; font-weight:bold; padding: 0px 0px 1px 0px'>Sơ lược nội dung</span>";
                HTML += "&nbsp;&nbsp;<div style='width:310px'>" + dt.Rows[0]["Content"].ToString() + "</div>";
            }

        }
        else
        {
            msg = new PccMsg();
            msg.CreateFirstNode("PDID", PDID);
            msg.CreateFirstNode("PrtID", "0");
            msg.CreateFirstNode("CatID", CatID);
            DataTable dt = cls.Get_pd_PropertyDetailByCondition_NonePro(msg.GetXmlStr.ToString()).Tables[0];

            if (dt.Rows.Count > 0)
            {
                HTML += "<span class='lbl_Property-BigSizeBoldD' style='color:green; font-weight:bold; padding: 0px 0px 5px 0px;white-space:nowrap'>Thông tin sản phẩm</span><br>";
                HTML += "<ul style='padding: 2px 2px 2px 15px; list-style-type:disc; margin: 0;'>";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[0]["PrtdDesc"].ToString() != "")
                        HTML += "<li style='white-space:nowrap'><span style='text-transform:capitalize; color:MidnightBlue;'>" + dt.Rows[i]["PrtNm"].ToString() + ":</span> <span class='lbl_PriceDetailD' style='font-size:12px'>" + dt.Rows[i]["PrtdDesc"].ToString() + "</span></li>";
                }
                HTML += "</ul>";
            }

        }







        return HTML;
    }

    private string Get_FooterInfo()
    {
        string HTML = "";
        DataSet ds = new DataSet();
        ds.ReadXml(Server.MapPath("~/Database/XML/FooterInfo.xml"));
        DataTable dt = ds.Tables[0];
        HTML += "<div style='background-color: White; padding: 5px; text-align: center; margin: 0px auto' class='div_skin-tango2'>";
        HTML += "  <table width='100%' cellpadding='0' cellspacing='0'><tr><td align='center'>";
        HTML += "<table cellpadding='2' cellspacing='0' width='80%' border='0'>";
        HTML += "<tr class='FooterInfoHeader'>";
        HTML += "<td nowrap width='30%'><span style='font-size:14px' class='lbl_Normal1'>Thông tin công ty<span></td>";
        HTML += "<td nowrap width='30%'><span style='font-size:14px' class='lbl_Normal1'>Chính sách công ty<span></td>";
        HTML += "<td nowrap width='30%'><span style='font-size:14px' class='lbl_Normal1'>Hướng dẫn khách hàng<span></td>";
        HTML += "</tr>";
        string str1 = "", str2 = "";
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            HTML += "<tr class='FooterInfoContent'>";
            SplipObject(dt.Rows[i]["Cols1"].ToString(), ref str1, ref str2);
            HTML += "<td nowrap><img border='0' src='" + ResolveUrl("~/") + "Images/Icon/IconBullet.jpg' style='padding-left: 1px' /> <a href='" + ResolveUrl("~/") + "Common/Contact/Contact.aspx?KindNo=" + str2 + "' class='lbl_Normal1'>" + str1 + "</a></td>";
            SplipObject(dt.Rows[i]["Cols2"].ToString(), ref str1, ref str2);
            HTML += "<td nowrap><img border='0' src='" + ResolveUrl("~/") + "Images/Icon/IconBullet.jpg' style='padding-left: 1px' /> <a href='" + ResolveUrl("~/") + "Common/Contact/Contact.aspx?KindNo=" + str2 + "' class='lbl_Normal1'>" + str1 + "</a></td>";
            SplipObject(dt.Rows[i]["Cols3"].ToString(), ref str1, ref str2);
            HTML += "<td nowrap><img border='0' src='" + ResolveUrl("~/") + "Images/Icon/IconBullet.jpg' style='padding-left: 1px' /> <a href='" + ResolveUrl("~/") + "Common/Contact/Contact.aspx?KindNo=" + str2 + "' class='lbl_Normal1'>" + str1 + "</a></td>";
            HTML += "</tr>";

        }
        HTML += "</table>";

        HTML += "  <img border='0' src='" + ResolveUrl("~/") + "Images/Icon/Footer/visa.jpg' style='padding-right: 20px' />";
        HTML += "</td></tr></table></div>";
        return HTML;
    }
    private void SplipObject(string str, ref string str1, ref string str2)
    {
        str1 = str.Split('^')[0];
        str2 = str.Split('^')[1];

    }


    private string GetInfoDetailPD()
    {
        clsWebShop cls = new clsWebShop();
        string PDID = cls.killSQLInjection(Request.QueryString["PDID"]);

        string CatID = "0";
        PccMsg msg = new PccMsg();
        msg.CreateFirstNode("PdID", PDID);
        DataTable dt = cls.Get_ProductByProductID(msg.GetXmlStr.ToString()).Tables[0];

        string HTML = "", HTML1 = "";
        if (dt.Rows.Count > 0)
        {
            if (dt.Rows[0]["Descript"].ToString().Trim() != "")
            {
                HTML1 += " <span class='lbl_Property-BigSizeBoldD' style='color:Green'>Chi tiết sản phẩm</span><br />";
                HTML1 += "<span class='lbl_PriceDetailD'>" + dt.Rows[0]["Descript"].ToString() + "</span>";
                CatID = dt.Rows[0]["CatID"].ToString();
            }
        }



        cls.UpdateViewCount(PDID);
        msg = new PccMsg();
        msg.CreateFirstNode("PDID", PDID);
        msg.CreateFirstNode("PrtID", "0");
        msg.CreateFirstNode("CatID", CatID);
        dt = new DataTable();

        //  dt = cls.Get_pd_PropertyDetailByCondition(msg.GetXmlStr.ToString()).Tables[0];
        dt = cls.Get_pd_PropertyDetailByCondition_NonePro(msg.GetXmlStr.ToString()).Tables[0];


        if (dt.Rows.Count > 0)
        {
            HTML += "<span class='lbl_Property-BigSizeBoldD' style='color:green'>Thông tin cơ bản</span><br>";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[0]["PrtdDesc"].ToString() != "")
                    HTML += "<span class='lbl_PriceDetailD'>- " + dt.Rows[i]["PrtNm"].ToString() + ": " + dt.Rows[i]["PrtdDesc"].ToString() + "</span><br>";
            }
        }
        HTML += HTML1;



        if (HTML == "")
            HTML = "<span class='lbl_Property-BigSizeBoldD' style='color:green'>Không có thông tin cho sản phẩm này </span>";

        return HTML;
    }
    #region GetCountBasket
    private string GetCountBasket()
    {
        DataTable dtHTML = new DataTable("Table");
        DataRow row = dtHTML.NewRow();
        dtHTML.Columns.Add("HTML1");
        dtHTML.Columns.Add("HTML2");
        dtHTML.Columns.Add("HTML3");
        DataTable dtBasket = (DataTable)Session["dtBasket"];
        DataTable dtBasketFilm = (DataTable)Session["dtBasketFilm"];
        if (dtBasket != null) row["HTML1"] = dtBasket.Rows.Count.ToString();
        else row["HTML1"] = "0";

        if (dtBasketFilm != null)
        {
            row["HTML3"] = dtBasketFilm.Rows.Count.ToString();
            try
            {
                //row["HTML2"] = dtBasket.Compute("sum(convert(float,replace(capacity,'GB','')))", "KindNo='F' and capacity <>''").ToString();
                DataRow[] dr = dtBasketFilm.Select("KindNo='F' and capacity <>''");
                decimal Capacity = 0;
                for (int i = 0; i < dr.Length; i++)
                {
                    Capacity += decimal.Parse(dr[i]["Capacity"].ToString().Replace("GB", ""));
                }
                row["HTML2"] = Capacity;

            }
            catch { row["HTML2"] = "0"; }
        }
        else
        {
            row["HTML2"] = "0";
            row["HTML3"] = "0";
        }

        dtHTML.Rows.Add(row);
        return GetJSONString(dtHTML);

    }

    private string UpdateQuantityBasket()
    {

        DataTable dtBasket = (DataTable)Session["dtBasket"];
        DataTable dtHTML = new DataTable("Table");
        dtHTML.Columns.Add("HTML1");
        dtHTML.Columns.Add("HTML2");
        dtHTML.Columns.Add("HTML3");
        if (Session["dtBasket"] != null)
        {
            string PDID = Request.QueryString["PDID"];
            string Quantity = Request.QueryString["Quantity"];

            clsCommon clsCom = new clsCommon();
            int index = clsCom.SearchDataTable(dtBasket, "PDID", PDID);
            if (index != -1) //Neu la loai san pham da ton tai thi cho phep so luong
            {
                dtBasket.Rows[index]["QUANTITY"] = Quantity;
            }

            string refPrice = Request.QueryString["refPrice"].Replace(",", "");
            string refRate = Request.QueryString["refRate"];
            string pMoneyRate = Request.QueryString["pMoneyRate"];

            decimal ThanhTien1dong = int.Parse(Quantity) * decimal.Parse(refPrice);
            if (refRate == "USD")
                ThanhTien1dong = ThanhTien1dong * decimal.Parse(pMoneyRate);
            DataRow row = dtHTML.NewRow();

            row["HTML1"] = ThanhTien1dong.ToString();


            int pQuantity = 0;
            decimal pTotal = 0;
            for (int i = 0; i < dtBasket.Rows.Count; i++)
            {
                int Q = int.Parse(dtBasket.Rows[i]["Quantity"].ToString());
                pQuantity += Q;
                string rate = dtBasket.Rows[i]["RATE"].ToString();
                pTotal += Q * decimal.Parse(dtBasket.Rows[i]["PRICE"].ToString());
                if (rate == "USD")
                {
                    pTotal = pTotal * decimal.Parse(pMoneyRate);
                }
            }

            row["HTML2"] = pQuantity.ToString();
            row["HTML3"] = pTotal.ToString();


            dtHTML.Rows.Add(row);


        }
        return GetJSONString(dtHTML);


    }

    #endregion
    #region COmmon
    private string LimitWord(string value, int length)
    {
        //String html = "Whatever your html is";
        //html = Regex.Replace(html, @"</?[^>]*>", ""); 
        if (value.Length > length)
            return value.Substring(0, value.Substring(0, length).LastIndexOf(" ")) + " ...";
        else
            return value;
        return value;

    }
    private string CancelAccentedVN(string accented)
    {
        System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\p{IsCombiningDiacriticalMarks}+");
        string strFormD = accented.Normalize(System.Text.NormalizationForm.FormD);
        return regex.Replace(strFormD, String.Empty).Replace('\u0111', 'd').Replace('\u0110', 'D').Replace(" ", "-").Replace("-", "-").Replace("/", "").Replace(@"\", "").Replace("\"", "").Replace("&", "");
    }
    private string FormatMoney(string sNum)
    {
        string sReturn = "0";
        try
        {
            sReturn = string.Format("{0:###,###,##0}", decimal.Parse(sNum));
        }
        catch (Exception) { }
        return sReturn;
    }
    private string FormatMoney(decimal dNum)
    {
        string sReturn = "0";
        try
        {
            sReturn = string.Format("{0:###,###,##0}", dNum);
        }
        catch (Exception) { }
        return sReturn;
    }
    private int SearchDataTable(DataTable dt, string Col, string value)
    {
        int index = -1;

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (dt.Rows[i][Col].ToString() == value)
            {
                index = i;
                break;
            }
        }
        return index;
    }
    public static string GetJSONString(DataTable Dt)
    {

        string[] StrDc = new string[Dt.Columns.Count];

        string HeadStr = string.Empty;
        for (int i = 0; i < Dt.Columns.Count; i++)
        {

            StrDc[i] = Dt.Columns[i].Caption;
            HeadStr += "\"" + StrDc[i] + "\" : \"" + StrDc[i] + i.ToString() + "¾" + "\",";

        }

        HeadStr = HeadStr.Substring(0, HeadStr.Length - 1);
        StringBuilder Sb = new StringBuilder();

        Sb.Append("{\"" + Dt.TableName + "\" : [");
        for (int i = 0; i < Dt.Rows.Count; i++)
        {

            string TempStr = HeadStr;

            Sb.Append("{");
            for (int j = 0; j < Dt.Columns.Count; j++)
            {

                TempStr = TempStr.Replace(Dt.Columns[j] + j.ToString() + "¾", Dt.Rows[i][j].ToString());

            }
            Sb.Append(TempStr + "},");

        }
        Sb = new StringBuilder(Sb.ToString().Substring(0, Sb.ToString().Length - 1));

        Sb.Append("]}");
        return Sb.ToString();

    }

    #endregion
}
